//按钮事件监听器
const {ccclass, property} = cc._decorator;

@ccclass
export class ButtonEventAgent extends cc.Component {
    start() {

    }

    onButtonClicked(evt: cc.Event, customEventData) {
        let btn = (evt.target as cc.Node).getComponent(cc.Button);
        let clickEvents = btn.clickEvents;
        for (let i = 0; i < clickEvents.length; ++i) {
            let h = clickEvents[i];
            if (h.customEventData == customEventData) {
                let cb = h['$cb$'];
                let target = h['$target$']
                let args = h['$args$'];
                cb.apply(target, [evt, args]);
            }
        }
    }
}
